package com.qzsoft.zhjd.common.enums;

/**
 * @ClassName YesOrNo
 * @Description 是否对象
 * @author linhuawei
 * @since 2022-03-29
 */
public enum YesOrNo {

    yes(1, "是"), no(0, "否");

    private int value;

    private String name;

    private YesOrNo(int value, String name) {
        this.value = value;
        this.name = name;
    }

    public int getValue() {
        return value;
    }

    public String getName() {
        return name;
    }

    /**
     * @Title includeValue
     * @Description 判断数据是否在合理范围内
     * @param value
     * @return
     */
    public static boolean includeValue(Integer value) {
        boolean include = false;
        if (null != value) {
            YesOrNo[] array = YesOrNo.values();
            for (YesOrNo enm : array) {
                if (value == enm.getValue()) {
                    include = true;
                    break;
                }
            }
        }
        return include;
    }

    /**
     * @Title nameArray
     * @Description 获取名称数组
     * @return
     */
    public static String[] nameArray() {
        YesOrNo[] array = YesOrNo.values();
        String[] names = new String[array.length];
        for (int i = 0, len = array.length; i < len; i++) {
            names[i] = array[i].getName();
        }
        return names;
    }

}
